package com.WOWTradeNews.tablet;


import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.WOWTradeNewsTest.R;

public class Default extends ActivityGroup{
	
	TextView ib1;    	
	TextView ib2;    	
	TextView ib3;    	
	TextView ib4;    	
	TextView ib5;
	    
    public void init(){
		DisplayMetrics dm = new DisplayMetrics();
		this.getWindowManager().getDefaultDisplay().getMetrics(dm);	
                        
    	ib1 =(TextView) findViewById(R.id.byMenu01);    	
    	ib2 =(TextView) findViewById(R.id.byMenu02);    	
    	ib3 =(TextView) findViewById(R.id.byMenu03);    	
    	ib4 =(TextView) findViewById(R.id.byMenu04);    	
    	ib5 =(TextView) findViewById(R.id.byMenu05);    	
    	
        ib1.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
            	ib1.setBackgroundResource(R.drawable.menu01a);
            	ib2.setBackgroundResource(R.drawable.menu02b);
            	ib3.setBackgroundResource(R.drawable.menu03b);
            	ib4.setBackgroundResource(R.drawable.menu04b);
            	ib5.setBackgroundResource(R.drawable.menu05b);
            	
            	Intent intent = new Intent(Default.this, ActivityInformationList.class);
            	chooseActivity(intent, R.id.tab_content_layout);
            }        	
        });    
        
        ib2.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {            	
            	ib1.setBackgroundResource(R.drawable.menu01b);
            	ib2.setBackgroundResource(R.drawable.menu02a);
            	ib3.setBackgroundResource(R.drawable.menu03b);
            	ib4.setBackgroundResource(R.drawable.menu04b);
            	ib5.setBackgroundResource(R.drawable.menu05b);
            	
              	Intent intent = new Intent(Default.this, TradeInformationList.class);
            	chooseActivity(intent, R.id.tab_content_layout);
            }        	
        });
        
        ib3.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {            	
            	ib1.setBackgroundResource(R.drawable.menu01b);
            	ib2.setBackgroundResource(R.drawable.menu02b);
            	ib3.setBackgroundResource(R.drawable.menu03a);
            	ib4.setBackgroundResource(R.drawable.menu04b);
            	ib5.setBackgroundResource(R.drawable.menu05b);
            
            	Intent intent = new Intent(Default.this, SpecialSubjectList.class);

            	chooseActivity(intent, R.id.tab_content_layout);
            }        	
        });

        ib4.setOnClickListener(new View.OnClickListener(){        	
            @Override
            public void onClick(View v) {            	
            	ib1.setBackgroundResource(R.drawable.menu01b);
            	ib2.setBackgroundResource(R.drawable.menu02b);
            	ib3.setBackgroundResource(R.drawable.menu03b);
            	ib4.setBackgroundResource(R.drawable.menu04a);
            	ib5.setBackgroundResource(R.drawable.menu05b);
            	
            	Intent intent = new Intent(Default.this, MarketResearchList.class);
            	chooseActivity(intent, R.id.tab_content_layout);
            }        	
        });
        
        ib5.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
            	ib1.setBackgroundResource(R.drawable.menu01b);
            	ib2.setBackgroundResource(R.drawable.menu02b);
            	ib3.setBackgroundResource(R.drawable.menu03b);
            	ib4.setBackgroundResource(R.drawable.menu04b);
            	ib5.setBackgroundResource(R.drawable.menu05a);

            	Intent intent = new Intent(Default.this, BookInformationList.class);
            	chooseActivity(intent, R.id.tab_content_layout);
            }        	
        });    	
    }
    
    public void chooseActivity(Intent intent, int intlayout){
        LocalActivityManager lm = getLocalActivityManager();
        
        LinearLayout layout = (LinearLayout) findViewById(intlayout);        
        
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Window w = lm.startActivity("asai", intent);
        View vi = w.getDecorView();
        layout.removeAllViews();
        layout.addView(vi,LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    }     
}